const Router = require('koa-router')
const momentRouter = new Router({ prefix: '/moment' })
const { verifyAuth, verifyPermission } = require('../middleware/auth.middleware')
const { create, momentDetail, momentList, updateMoment, deleteMomentById } = require('../controller/moment.controll')
// 1.用户发表动态需要先验证授权
momentRouter.post('/', verifyAuth, create)
// 查询多条评论
momentRouter.get('/', momentList)
// 2.查询一条评论
momentRouter.get('/:momentId', momentDetail)
// 修改一条评论
// 1.验证用户已经登陆
// 2.校验用户是否具有修改当前数据的权限
// 3.对具体的评论进行更新
momentRouter.patch('/:momentId', verifyAuth, verifyPermission, updateMoment)
// 根据id删除对应moment
momentRouter.delete('/:momentId', verifyAuth, verifyPermission, deleteMomentById)

module.exports = momentRouter
